package com.example.tutorial.greendao;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;

public class GreenDaoGenerator {
	public static void main(String[] args) throws Exception {
		Schema schema = new Schema(1000, "com.example.tutorial.model");

		addUser(schema);
		addTask(schema);
		
		// can tao thu muc D:\\greendao truoc khi gen
		new DaoGenerator().generateAll(schema, "D:\\greendao");
	}

	// gen bang User
	private static void addUser(Schema schema) {
		Entity note = schema.addEntity("User");
		note.addIdProperty().autoincrement().primaryKey();
		note.addStringProperty("userName").notNull();
		note.addStringProperty("password");
	}
	
	// gen bang task
	private static void addTask(Schema schema) {
		Entity note = schema.addEntity("Task");
		note.addIdProperty().autoincrement().primaryKey();
		note.addStringProperty("title").notNull();
		note.addStringProperty("content");
		note.addIntProperty("userId").notNull();
		note.addBooleanProperty("isSynchronize").notNull();
		note.addDateProperty("notifyDate").notNull();
		note.addDateProperty("dateCreated").notNull();
	}
}
